package io.netty.example.test;

import java.nio.ByteBuffer;

/**
 * Created by gaoshengjie on 2015/2/15.
 */
public class NioBuffer {
    public static void main(String[] args) {
        ByteBuffer buffer=ByteBuffer.allocate(1024);

        System.out.println(buffer.array().length);
        System.out.println(buffer.arrayOffset());
        System.out.println(buffer.capacity());
        System.out.println(buffer.clear());
        System.out.println(buffer.hasArray());
        System.out.println(buffer.hasRemaining());
        System.out.println(buffer.isDirect());
        System.out.println(buffer.limit());
        buffer.mark().position(100);
        System.out.println(buffer);
        buffer.reset();
        System.out.println("rest"+buffer);

        buffer.put((byte) 1);
        System.out.println(buffer.get(0) & 0xff);
        buffer.put(100, (byte) 3);
        ByteBuffer slice=buffer.slice();
        //slice.put(0, (byte) 2);
        System.out.println(slice.get(99));
    }
}
